<template>
	<div>
    <easytable :tableData="chapterList" :columns="columns" :total="total" ref="table"
			@pageChange="pageChange" @pageSizeChange="pageSizeChange">
		</easytable>
	</div>
</template>

<script>
import easytable from '@/views/components/table/table'
export default {
	data() {
		return {
			chapterList: [],
			total: null,
      columns: [
        {field: 'id', title: 'id', width: 1, titleAlign: 'center', columnAlign: 'center', isResize: true},
        {field: 'courseId', title: '课程id', width: 1, titleAlign: 'center', columnAlign: 'center', isEdit: true, isResize: true},
        {field: 'name', title: '大章名称', width: 1, titleAlign: 'center', columnAlign: 'center', isEdit: true, isResize: true},
				{
					field: 'customeOption',
					title: '操作',
					width: 1,
					titleAlign: 'center',
					columnAlign: 'center',
					componentName: 'tableOperation',
					isResize: true
				}
      ]
		}
	},
	components: {
		easytable
	},
	mounted() {
		this.list()
	},
	methods: {
		list() {
			let tableNode = this.$refs.table
			let param = {pageIndex: tableNode.pageIndex, pageSize: tableNode.pageSize}
			this.$axios.post('http://localhost:9000/business/admin/chapter/list', param)
				.then(res => {
					let data = res.data.data
					this.chapterList = data.list
					this.total = data.total
				})
		},
		pageChange() {
			this.list()
		},
		pageSizeChange() {
			this.list()
		}
	}
}
</script>

<style>
</style>
